﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Kunde/WebsiteCustomer.master" AutoEventWireup="true" CodeBehind="Rabat.aspx.cs" Inherits="TireService.Website.Kunde.Rabat" %>

<%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%@ Register assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxPanel" tagprefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxLoadingPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxCallbackPanel" TagPrefix="dx" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="content" runat="server">

    <dx:ASPxLoadingPanel ID="LoadingPanel" Text="Vent venligst..." ClientInstanceName="LoadingPanel" runat="server" Modal="True">
    </dx:ASPxLoadingPanel>

    <script type="text/javascript" language="javascript">

        function SendQuotationCode() {
            // Validate value
            txtEmail.Validate();

            var isFormValid = ASPxClientEdit.ValidateGroup("SendQuotationCode");
            if (isFormValid) {
                // Show loadingpanel while doing postback
                LoadingPanel.Show();

                var input = txtEmail.GetText() + '|' + ddlSubscription.GetValue() + '|' + txtMessage.GetText();

                callbackSendQuotation.PerformCallback(input);
            }
        }

        function OnCallbackSendQuotationComplete(s, e) {
            txtEmail.SetText('');

            LoadingPanel.Hide();

            gvQuotation.PerformCallback();

            alert('Email sendt');
        }

        function CallBackError(s, e) {
            LoadingPanel.Hide();
        }

    </script>

    <dx:ASPxCallback ID="callbackSendQuotation" ClientInstanceName="callbackSendQuotation"
        runat="server" OnCallback="callbackSendQuotation_Callback">
        <ClientSideEvents CallbackError="CallBackError" CallbackComplete="OnCallbackSendQuotationComplete" />
    </dx:ASPxCallback>

    <h3>Få op til 25% rabat på dit abonnement</h3>
    Når du henviser venner, kolleger eller familie kreditere vi med en økonomisk fordel for både dig og dem<br />
    <br />
    10% rabat på 1. års abonnement til den du henviser<br />
    <br />
    5% rabat til dig for hver du henviser og som bliver kunde hos Mobilhjulskift.dk, dog max. 25 %*<br />
    <br />
    * Rabatten gælder kun en gang og modregnes i den næste fornyelse af abonnement. Rabat kan ikke udbetales eller overdrages.<br />
    <hr />
    <h3>Send rabatkode</h3>
    <table>
        <tr>
            <td>
                Vælg produkt
            </td>
            <td>
                <dx:ASPxComboBox ID="ddlSubscription" ClientInstanceName="ddlSubscription" runat="server" Width="200px">
                    <Items>
                        <dx:ListEditItem Value="6" Text="BronzePlus abonnement, årlig" Selected="true" />
                        <dx:ListEditItem Value="1" Text="Bronze abonnement, årlig" />
                    </Items>
                </dx:ASPxComboBox>
            </td>
        </tr>
        <tr>
            <td>Email på modtager</td>
            <td>
                <dx:ASPxTextBox ID="txtEmail" ClientInstanceName="txtEmail" NullText="Indtast modtager email" runat="server" Width="200px">
                    <ValidationSettings RegularExpression-ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                        ErrorDisplayMode="ImageWithTooltip" RegularExpression-ErrorText="Email ikke gyldig"
                        RequiredField-IsRequired="true" RequiredField-ErrorText="Indtast email adresse"
                        ValidationGroup="SendQuotationCode">
                    </ValidationSettings>
                </dx:ASPxTextBox>
            </td>
        </tr>
        <tr>
            <td valign="top">Inkluder personlig besked</td>
            <td>
                <dx:ASPxMemo ID="txtMessage" ClientInstanceName="txtMessage" NullText="Skriv en besked" runat="server" Height="100px" Width="200px">
                </dx:ASPxMemo>
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
                <dx:ASPxButton ID="btnSendQuotationCode" ClientInstanceName="btnSendQuotationCode" runat="server" Text="Send rabatkode" AutoPostBack="False" UseSubmitBehavior="False">
                    <ClientSideEvents Click="function(s, e) { SendQuotationCode(); }" />
                </dx:ASPxButton>
            </td>
        </tr>
    </table>
    <hr />
    <h3>Udsendte rabatkoder</h3>
    <dx:ASPxGridView ID="gvQuotation" runat="server" ClientInstanceName="gvQuotation" oncustomunboundcolumndata="gvQuotation_CustomUnboundColumnData"
        KeyFieldName="QuotationId" AutoGenerateColumns="False" EnableCallBacks="True" OnCustomCallback="gvQuotation_CustomCallback">
        <SettingsLoadingPanel Text="Henter&amp;hellip;" />
        <SettingsPager AlwaysShowPager="false" PageSize="10" Position="Bottom">
            <Summary 
                AllPagesText="Sider: {0} - {1} ({2} rabatkoder)" 
                Text="Side {0} af {1} ({2} rabatkoder)" />
        </SettingsPager>
        <SettingsText EmptyDataRow="Ingen rabatkoder udsendt endnu" />
        <SettingsBehavior ConfirmDelete="True" AllowGroup="true" AllowDragDrop="true" />
        <Columns>                    
            <dx:GridViewDataColumn FieldName="QuotationId" VisibleIndex="1" Caption="QuotationId" Visible="false">
            </dx:GridViewDataColumn>
            <dx:GridViewDataColumn FieldName="QuotationCode" VisibleIndex="1" Caption="QuotationCode" Visible="false">
            </dx:GridViewDataColumn>
            <dx:GridViewDataTextColumn FieldName="FullQuotationCode" VisibleIndex="1" UnboundType="String" Caption="Rabatkode">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataColumn FieldName="Createdate" VisibleIndex="2" Caption="Oprettet">
            </dx:GridViewDataColumn>
            <dx:GridViewDataColumn FieldName="Activationdate" VisibleIndex="3" Caption="Aktiveret">
            </dx:GridViewDataColumn>
            <dx:GridViewDataColumn FieldName="SendOutEmail" VisibleIndex="4" Caption="Sendt til">
            </dx:GridViewDataColumn>
        </Columns>                                            
    </dx:ASPxGridView>

</asp:Content>
